#管理员登录
import requests

login_url = "http://ihrm-test.itheima.net/api/sys/login"
headers = {"Content-Type":"application/json"}
body = {"mobile": "13800000002","password": "123456"}
resp = requests.post(url=login_url,headers=headers,json=body)
print("登录:",resp.json())
token = "Bearer "+resp.json().get('data')


#员工新增你
add_user_url = "http://ihrm-test.itheima.net/api/sys/user"
headers = {"Content-Type":"application/json","Authorization":token}
body = {
    "username": "xiaoxiami001",
    "mobile": "13912344322",
    "workNumber":"000111"
}
resp = requests.post(url=add_user_url,headers=headers,json=body)
print("新增：",resp.json())


#员工查询
query_url = "http://ihrm-test.itheima.net/api/sys/user/1520693518018920448"
headers = {"Content-Type":"application/json","Authorization":token}
resp = requests.get(url=query_url,headers=headers)
print("查询：",resp.json())


#员工修改
modify_url = "http://ihrm-test.itheima.net/api/sys/user/1520693518018920448"
headers = {"Content-Type":"application/json","Authorization":token}
body = {"username": "xiaoxiami002","password": "12345678"}
resp = requests.put(url=modify_url,headers=headers,json=body)
print("修改：",resp.json())


#员工删除
delete_url = "http://ihrm-test.itheima.net/api/sys/user/1520693518018920448"
headers = {"Content-Type":"application/json","Authorization":token}
resp = requests.delete(url=delete_url,headers=headers)
print("删除：",resp.json())